@using DNA.Mvc.Text;
@model Post
@{
    var post = new PostWrapper(Model);
    Post model = ViewBag.Editing != null ? ViewBag.Editing : null;
}
<div style="padding: 10px;">
    <h1>
        @(Html.Global("forums", "Reply") + " :")
        <span style="color: Gray;">@Model.Title</span>
    </h1>
    <hr />
    <div class="d-forums-post-body">
        <table style="width: 100%">
            <tr>
                <td class="d-forums-post-profile" style="vertical-align: top;">
                    <div style="display: inline-block">
                        <img src="@Url.Content("~/content/images/calendar_empty_16.png")" alt="postby" style="float: left;" />
                        @Html.Global(post.Posted)
                    </div>
                    @if (post.UserProfile != null)
                    {
                        Html.RenderPartial("UserInfo", post.UserProfile);
                    }
                </td>
                <td class="d-forums-post-content"  style="vertical-align: top;">
                    <div style="height: 300px; overflow: auto;">
                        @TextEngine.BBCode(post.Body, true, false, true)
                    </div>
                    @if (!Request.Browser.Browser.Equals("IE", StringComparison.OrdinalIgnoreCase))
                    {
                        <div style="margin-top: 10px;">
                            @Ajax.Dna().Button().Text(Html.Global("forums", "Quote")).Click("_getQuoteSelection();").GetHtml()
                            Select no text to quote the entire message, or select a portion for quoting specific
                            text.
                        </div>
                    }
                </td>
            </tr>
        </table>
    </div>
    <hr />
    @(
    Ajax.Dna().Button().LocText("RES_CANCEL").Click("location=\""+Url.Action("Index", "Thread", new { id = Model.Thread.ID, Area = "Community" })+"\";")
    .ImageIcons(Url.Content("~/content/images/icon_back_16.png"))
                   .GetHtml()
    )
</div>
@{
    var _vData = new ViewDataDictionary();
    _vData["Forum"] = Model.Thread.Forum;
    _vData["TitlePrefix"] = Html.Global("forums", "ReplyPrfix") + ":" + Model.Title;
    _vData["ThreadPost"] = Model.Thread.ThreadPost;
    if (model != null)
    {
        _vData.Model = model;
    }
    Html.RenderPartial("PostForm", _vData);
}
<script type="text/javascript">
    function _getQuoteSelection() {
        var selectedText = "";
        if ($.browser.msie) {
            var _selection = document.selection.createRange();
            selectedText = _selection.text;
        }
        else {
            selectedText = window.getSelection().toString();
        }
        var quoteTxt = "[quote=@(post.UserName)]" + selectedText + "[/quote]";
        var postBody = $("#Post_Body").val();
        $("#Post_Body").val(postBody + "\r\n" + quoteTxt);
    }
</script>
